import { Housework } from '@prisma/client';
import {ApiProperty} from "@nestjs/swagger";
import {Exclude} from "class-transformer";
import {userEntity} from "../../user/entities/user.entity";
import {companyEntity} from "../../company/entities/company.entity";
import {ServerTypeEntity} from "../../server-type/entities/server-type.entity";

export class houseworkEntity implements Housework {
  constructor({ user,company,server, ...data }: Partial<houseworkEntity>) {
    Object.assign(this, data);
    if (user) {
      this.user = new userEntity(user);
    }
    if(company){
      this.company = new companyEntity(company);
    }
    if (server){
      this.server = new ServerTypeEntity(server);
    }
  }
  @ApiProperty()
  address: string;
  @ApiProperty()
  companyId: string;
  @ApiProperty()
  @Exclude()
  createdAt: Date;
  @ApiProperty()
  id: string;
  @ApiProperty()
  isCount: number;
  @ApiProperty()
  serverId: string;
  @ApiProperty()
  serverTime: Date;
  @ApiProperty()
  @Exclude()
  updatedAt: Date;
  @ApiProperty()
  userId: string;
  @ApiProperty({ required: true, type: userEntity })
  user?: userEntity;
  @ApiProperty({ required: true, type: companyEntity })
  company?: companyEntity;
  @ApiProperty({ required: true, type: ServerTypeEntity })
  server?: ServerTypeEntity;

}
